<?php
include_once 'checkLogin.php';
include_once 'db/li.php';
@$userId = $_SESSION['userId'];
@$data2 = null;
@$data = dbSelect('select role.name as role_name,worker.name as worker_name,worker.id as worker_id,imgUrl from user 
					join worker on user.id=worker.user_id 
					join role on worker.role_id=role.id where user.id=:id',array('id'=>$userId));
if($userId != 1 && $userId != 4){
	@$data2 = dbSelect('select branch.name as branch_name from worker join branch on worker.branch_id=branch.id where worker.id=:id',array('id'=>$data['worker_id']));
}

@$branchs = dbSelectAll('select id,name,phone from branch');
?>
<!DOCTYPE html>
<html>
	<head>
      <title>nav</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="bootstrap/css/bootstrap-editable.css" rel="stylesheet">
      <link href="bootstrap/css/fileinput.css" rel="stylesheet">
      <link href="bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
      <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
      <script src="bootstrap/js/bootstrap.min.js"></script>
      <script src="bootstrap/js/bootstrap-editable.js"></script>
      <script src="bootstrap/js/fileinput.js"></script>
      <script src="bootstrap/js/bootstrap-datetimepicker.min.js"></script>
      <script src="bootstrap/js/bootstrap-datetimepicker.zh-CN.js"></script>
      <!--[if lt IE 9]>
         <script src="bootstrap/js/html5shiv.js"></script>
         <script src="bootstrap/js/respond.min.js"></script>
      <![endif]-->
      <script src="db/dialog.js"></script>
      <script src="db/logOut.js"></script>
      <style>
      	*{ margin:0; padding:0; }
      	body{ font-family:"楷体"; font-weight:800; font-size:15px; }
      	#bigBox{ margin-left:50px; margin-right:50px; }
      	/*.panel{ border:1px solid blue; }
      	.panel-heading{ background:blue; }*/
      	.myDialog{ width:400px; margin:100px auto; }
      	.table,.table th{ text-align:center; }
      	.smallImg{ width:30px; height:30px; }
      	
      	.navbar{ line-height:48px; width:100%; }
      	.navbar-header{ font-size:30px; margin-left:50px; }
      	.nav_worker{ width:40px; height:40px; margin-top:-4px; }
      	.nav_name{ font-size:20px; }
      	.logOutBtnBox{ padding-top:2px; font-size:20px; }
      	
      	.imgbox{ position:relative; height:800px; }					/*index*/
      	.imgbox img{ width:200px; height:100px; border:1px solid blue; border-radius:50%; position:absolute; margin-left:-100px; }
      	.imgbox #img1{ left:50%; top:100px; }
      	.imgbox #img2{ left:62%; top:220px; }
      	.imgbox #img3{ left:74%; top:340px; }
      	.imgbox #img4{ left:62%; top:460px; }
      	.imgbox #img5{ left:50%; top:580px; }
      	.imgbox #img6{ left:38%; top:460px; }
      	.imgbox #img7{ left:26%; top:340px; }
      	.imgbox #img8{ left:38%; top:220px; }
      	
      	.branchNameListImg{ width:200px; height:500px; }
      </style>
      <script>
      	$.ajaxSetup({
			dataType:'JSON',
			error:function(){
				$.message('消息提示','crm与服务器交互出错');
			}
        })
		$(function(){
			var a;
			var img = $('.imgbox img');
			function run(){									
				a = setInterval(function(){
					var leftq = img.eq(0).position().left;
					var topq = img.eq(0).position().top;
					for(var i=1;i<=img.length;i++){
						if(i == img.length){
							img.eq(i-1).stop(true).animate({left:leftq,top:topq},1000);
						}
						var left = img.eq(i).position().left;
						var top = img.eq(i).position().top;
						img.eq(i-1).stop(true).animate({left:left,top:top},1000);
					}
				},3000);
			}
			run();
			img.hover(function(){
				clearInterval(a);
				$(this).animate({width:'250px',height:'120px'},500);
			},function(){
				run();
				$(this).animate({width:'200px',height:'100px'},500);
			});
		});  
      </script>
   	</head>
	<body>
   		<nav class='navbar' style='background:#ddd0dd;'>
   			<div class='navbar-header'>
   				<a href='index.php'>CRM</a>
   				&nbsp;客户关系管理
   			</div>
   			<div class='row'>
   				<div class='col-xs-3 col-xs-offset-5'>
		   			<img src='img/worker/<?php echo $data['imgUrl'];?>' class='nav_worker' />&nbsp;
		   			<span class='nav_name'><?php echo $data['worker_name'];?></span>
		   			<span>《<?php echo $data['role_name'];?>》</span>
		   			<?php if(!empty($data2)){?>
			   			<span><?php echo $data2['branch_name'];?></span>
		   			<?php }?>
   				</div>
   				<div class='col-xs-1 logOutBtnBox'>
		   			<a href='#' id='logOutBtn'>退出登录</a>
   				</div>
   			</div>
	   	</nav>
	   	<div id='bigBox'>
			<div class='row'>
				<div class='col-xs-2'>
					<div class='list-group text-center'>
						<a class='list-group-item' style='background:blue;'>菜单列表</a>
						<a class='list-group-item' href='ediWorkerBasic.php?worker_id=<?php echo $data['worker_id'];?>'>修改个人基本信息</a>
						<a class='list-group-item' href='ediWorkerLog.php?worker_id=<?php echo $data['worker_id'];?>'>修改个人登录信息</a>
						
						<a class='list-group-item' href='branchList.php'>查看所有部门</a>
						<a class='list-group-item' href='addBranch.php'>添加部门</a>
						
						<a class='list-group-item' href='branchNameList.php'>查看部门主管</a>
						<a class='list-group-item' href='clientManaList.php'>查看客户经理</a>
						
						<a class='list-group-item' href='workerList.php'>查看所有职员</a>
						<a class='list-group-item' href='addWorker.php'>添加职员</a>
					</div>
				</div>
	   	
	   	
	   	
	   	
	   	
	   	
	   	
	   	
	   	
	   	
	   	
 